package com.monster.controller;

import com.monster.entity.QueryPageBean;
import com.monster.entity.Result;
import com.monster.pojo.CheckItem;
import com.monster.pojo.User;
import com.monster.service.CheckItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "检查项管理开发")  // 作用在类上

public class CheckItemController {

    @Reference
    private CheckItemService checkItemService;

    @GetMapping("web/checkitem/findAll")
    public Result findAll(){
        return new Result(checkItemService.list());
    }
    //  查询所有的检查项信息   Result   响应数据规范   json 格式数据
    //   后续业务出错  bug   采用全局异常捕捉  响应前端
    @ApiOperation(value = "检查项列表查询",notes = "根据客户端请求，完成检查项所有信息列表查询")//   添加业务方法上
    @PostMapping("web/checkitem/findRecoverPage")
    public Result findRecoverPage(@RequestBody QueryPageBean queryPageBean){
        return  new Result(checkItemService.findRecoverPage(queryPageBean));
    }

    @PostMapping("web/checkitem/findPage")
    @ApiOperation(value = "分页查询",notes = "根据客户端请求，完成分页查询")//   添加业务方法上
    @ApiImplicitParams({
            @ApiImplicitParam(name="currentPage",value="当前分页页码",required=true,paramType="form",dataType="Integer"),
            @ApiImplicitParam(name="pageSize",value="每页显示记录数",required=true,paramType="form",dataType="Integer"),
            @ApiImplicitParam(name="queryString",value="查询条件",required=false,paramType="form",dataType="String")
    })
    public Result findPage(@RequestBody QueryPageBean queryPageBean){
        return   new Result(checkItemService.findPage(queryPageBean));
    }
    @PostMapping("web/checkitem/addAndUpdata")
    public Result updateAndAdd(@RequestBody CheckItem checkItem){
        return new Result(checkItemService.saveOrUpdate(checkItem));
    }
    //逻辑删除
    @DeleteMapping("web/checkitem/deleteCheckItemById/{id}")
    public Result deleteCheckitemById(@PathVariable("id") int id){
       return new Result(checkItemService.deleteCheckitemById(id));
    }
    //历史恢复
    @PutMapping("web/checkitem/recoverCheckItemById/{id}")
    public Result recoverCheckItemById(@PathVariable("id") int id){
        return new Result(checkItemService.recoverCheckItemById(id));
    }
}








